//
//  OneImageTableViewCell.m
//  MusicNews
//
//  Created by lanou3g on 15/10/13.
//  Copyright © 2015年 LC.J. All rights reserved.
//

#import "OneImageTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "NewsModel.h"
@implementation OneImageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if ([UIScreen mainScreen].bounds.size.width == 320) {
            _titleImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 60)];
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, self.bounds.size.width - 120, 20)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 35, self.bounds.size.width - 140, 40)];
            _replyCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 87, self.bounds.size.height + 18, 80, 20)];
            _replyCountLabel.textAlignment = NSTextAlignmentRight;
        }else if([UIScreen mainScreen].bounds.size.width == 375){
            _titleImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 60)];
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, self.bounds.size.width - 50, 20)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 35, self.bounds.size.width - 50, 40)];
            _replyCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 10, self.bounds.size.height + 18, 80, 20)];
        }else{
            _titleImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 60)];
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, self.bounds.size.width - 10, 20)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 35, self.bounds.size.width - 10, 40)];
            _replyCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width + 20, self.bounds.size.height + 18, 80, 20)];
        }
        
        
        _introduceLabel.numberOfLines = 0;
        _introduceLabel.font = [UIFont systemFontOfSize:15];
        _introduceLabel.alpha = 0.8;
        
        _replyCountLabel.font = [UIFont systemFontOfSize:13];
        _replyCountLabel.alpha = 0.7;
        
        [self addSubview:_titleImage];
        [self addSubview:_titleLabel];
        [self addSubview:_introduceLabel];
        [self addSubview:_replyCountLabel];
    }

    return self;
    
}




-(void)setNewsModel:(NewsModel *)newsModel{
    _newsModel = newsModel;
    /**
     *@property (nonatomic, strong) UILabel *titleLabel;
     @property (nonatomic, strong) UILabel *introduceLabel;
     @property (nonatomic, strong) UILabel *replyCountLabel;
     @property (nonatomic, strong) NewsModel *newsModel;
     @property (nonatomic, strong) UIImageView *titleImage;
     */
    
    [_titleImage sd_setImageWithURL:[NSURL URLWithString:self.newsModel.imgsrc] placeholderImage:[UIImage imageNamed:@"Kplace"]];
    
    _titleLabel.text = self.newsModel.title;
    _introduceLabel.text = self.newsModel.digest;
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
